package com.som.beanconvert.data2.input;

import java.util.HashMap;
import java.util.Map;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.ss.usermodel.Row;

import com.som.bean.data1.output.IpaddressJoin;
import com.som.beanconvert.ExcelDataParseInputInf;
import com.som.beanconvert.ExcelRowDataParseProcessInf;
import com.som.util.ExcelCellStrGet;

/**
 * 全量IP地址(输入文件名为input1.xls),此文件即为需求一：设备采集数据和资管系统数据比对的输出结果1, 输入列为: IP地址
 * 路由(network) 网元信息 区县
 * 
 * 进行数据的从excel转换到java对象
 * 
 * @author liujun
 * @date 2016年4月8日
 * @verion 0.0.1
 */
public class IpaddressJoinExcelInput extends IpaddressJoin implements ExcelDataParseInputInf<IpaddressJoin>, ExcelRowDataParseProcessInf<String, IpaddressJoin>
{

	public Map<String, IpaddressJoin> parseRowDataProcess(IpaddressJoin t)
	{

		if (null != t)
		{
			Map<String, IpaddressJoin> map = new HashMap<String, IpaddressJoin>();

			// ip为键，其他信息为值，进行数据的合并
			map.put(t.getIpaddress(), t);

			return map;
		}

		return null;

	}

	public IpaddressJoin parseBean(Row excelRow)
	{
		IpaddressJoin result = new IpaddressJoin();

		HSSFRow row = (HSSFRow) excelRow;

		// IP地址
		HSSFCell cellip = row.getCell(0);
		result.setIpaddress(ExcelCellStrGet.getCellValue(cellip));

		// 路由(network)
		HSSFCell cellNetWork = row.getCell(1);
		result.setNetwork(ExcelCellStrGet.getCellValue(cellNetWork));

		// 网元信息
		HSSFCell cellNe = row.getCell(2);
		result.setNeInfo(ExcelCellStrGet.getCellValue(cellNe));

		// 区县
		HSSFCell cellarea = row.getCell(3);
		result.setAreainfo(ExcelCellStrGet.getCellValue(cellarea));

		return result;
	}

}
